<html>
<head>
	<meta charset='utf-8' />
	<title>小区信息助手后台</title>
	<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" />
	<style>
		@media screen and (max-width:450px){
			#content,.nav_div{width:98%;margin:0 auto}
			/*页面宽度900以下时 .abc的宽度为450*/
		}
		@media screen and (min-width:450px){
			#content,.nav_div{width:450px;margin:0 auto}
			/*页面宽度900以下时 .abc的宽度为450*/
		}
		.red{color:red;}
		.blue{color:blue;}
		.a{padding:0 5px;font:normal bold 15px/30px normal;text-align:center}
		.b{flex:1;overflow:hidden;font:normal bold 15px/30px normal;text-align:center;white-space: nowrap;margin:0 5px}
		.c{border-radius:50px;height:30px;width:30px}
		.d{display:flex;margin:5px 0;}
	</style>
</head>
<body>
<div id='content' style='position:relative'>
	<h1 style='text-align:center'>小区成员管理</h1>

	<div style='text-align:center'>
		<label><input type="radio" name='userType' checked  value='all'/>全部</label>　
		<label><input type="radio" name='userType' value='admin' />管理</label>　
		<label><input type="radio" name='userType' value='normal'/>普通</label>
	</div>

	<!--div style='margin:20px 0;text-align:centers'>
		<label><input type="radio" value='all' name='area_type' checked /> 全部</label>
		<label><input type="radio" value='1' name='area_type' />正常</label>
		<label><input type="radio" value='2' name='area_type' />禁言</label>
		<label><input type="radio" value='3' name='area_type' />永封</label>
	</div-->

	<div id='user_list'>
		
		<!--div class='d'>
			<div style='width:40px'><img src="http://thirdwx.qlogo.cn/mmopen/vi_32/KbsMOauZmxL64AVsAUp51aBNyrRwibhQmz5r4ddMrn3feHCgFhZdv4PIrIPdTH57GnkH3qO3nIzn3peNiaNQEgHA/132" alt="" class='c'></div>   
			<div class='b'> freesdfsdfdsfsdfssdfsdfsdfsdfsdfdfsdfsdfsdfsdf loop </div>  <div class='a'>超管</div>  <div class='a'>正常</div>  <div class='a'>更改状态</div>
		</div-->

	</div>

	<div id='fpage' style='text-align:center;margin:20px'></div>


	<div style='text-align:center;margin:50px'>
		<button onclick='history.go(-1)'>返回</button>
	</div>


</div>


</body>
</html>
<script src='../public/jquery.js'></script>
<script src='../public/fun.js'></script>
<script>
if(!sessionStorage.after_con_area_user_list_pnow){
	sessionStorage.after_con_area_user_list_pnow = 1;
}

$(function(){
	if(sessionStorage.after_con_area_user_userType){
		$('input[name=userType]').each(function(i,o){
			if($(o).val() == sessionStorage.after_con_area_user_userType){
				o.checked = true;
			}
		});
	}else{
		sessionStorage.after_con_area_user_userType = $('input[name=userType]:checked').val();
	}
	$('input[name=userType').click(function(){
		sessionStorage.after_con_area_user_userType = $(this).val();
		sessionStorage.after_con_area_user_list_pnow = 1;
		location.reload();
	});
	//底部导航与显示页面
	// $.ajax({
	// 	url:'after_template_bottom_nav.html',
	// 	success(res){
	// 		$('body').append(res);
	// 	}
	// });

	GetAreaUserList();


});


//获取小区用户列表
function GetAreaUserList(){
	var userType = sessionStorage.after_con_area_user_userType;
	var data = {
		type:'GetAreaUserList',
		id:sessionStorage.after_current_area_id,
		city_code:sessionStorage.after_current_area_cityCode,
		db_name:sessionStorage.after_current_area_dbName,
		db_host:sessionStorage.after_current_area_dbHost,
		userType:userType,
		pnow:sessionStorage.after_con_area_user_list_pnow
	}
	AjaxAfter(data,function(res){
		if(!/^{.*}$/.test(res)){
			return;
		}
		var tmp = JSON.parse(res);
		sessionStorage.admin_token1 = tmp.token1;
		if(tmp.stat == 'err1'){
			A('请求异常！');return;
		}
		if(tmp.data){
			ParseUserList(tmp.data);
		}
	});
}

/*
	<div id='area_list'>
		
		<div class='d'>
			<div style='width:40px'><img src="http://thirdwx.qlogo.cn/mmopen/vi_32/KbsMOauZmxL64AVsAUp51aBNyrRwibhQmz5r4ddMrn3feHCgFhZdv4PIrIPdTH57GnkH3qO3nIzn3peNiaNQEgHA/132" alt="" class='c'></div>   
			<div class='b'> freesdfsdfdsfsdfssdfsdfsdfsdfsdfdfsdfsdfsdfsdf loop </div>  <div class='a'>超管</div>  <div class='a'>正常</div>  <div class='a'>更改状态</div>
		</div>

	</div>
*/

function ParseUserList(data){
	if(typeof(data) != 'object' || data.length < 1){
		Fpage(sessionStorage.after_con_area_user_list_pnow,parseInt(sessionStorage.after_con_area_user_list_pnow),function(p){
			sessionStorage.after_con_area_user_list_pnow = p;
			GetAreaUserList();
		},1,1,'#fpage');

		$('#user_list').html('');
		return;
	}
	var str = '';
	for(var i=0;i<data.length;i++){
		switch(data[i].level){
			case '1':case 1:
				var level_name = '<span class="red">超管</span>';
				break;
			case '2':case 2:
				var level_name = '<span class="blue">管理</span>';
				break;
			case '3':case 3:
				var level_name = '普通';
				break;
		}

		switch(data[i].stat){
			case 1:case '1':var stat_name = '正常';break;
			case 2:case '2':var stat_name = '<span style="color:blue">暂封</span>';break;
			case 3:case '3':var stat_name = '<span style="color:red">永封</span>';break;
		}
		str += "<div class='d'><div style='width:40px'><img src='http://thirdwx.qlogo.cn/mmopen/vi_32/KbsMOauZmxL64AVsAUp51aBNyrRwibhQmz5r4ddMrn3feHCgFhZdv4PIrIPdTH57GnkH3qO3nIzn3peNiaNQEgHA/132' alt='' class='c'></div><div class='b'> free loop </div>  <div class='a' onclick=ChangeAreaUserLevel("+data[i].area_id+",'"+data[i].openid+"')>" +level_name+ "</div>  <div class='a' onclick=ChangeAreaUserStat("+data[i].area_id+",'"+data[i].openid+"')> "+ stat_name +" </div></div>";
	}
	$('#user_list').html(str);

	//var max_page = MainGoods_Max?MainGoods_Max:MainGoods_Pnow+1;
	Fpage(sessionStorage.after_con_area_user_list_pnow,parseInt(sessionStorage.after_con_area_user_list_pnow)+1,function(p){
		sessionStorage.after_con_area_user_list_pnow = p;
		GetAreaUserList();
	},1,1,'#fpage');
}


//更改小区用户级别
function ChangeAreaUserLevel(area_id,openid){
	if(!confirm('确认操作该用户级别？')){
		return;
	}
	var data = {
		type:'ChangeAreaUserLevel',
		area_id:area_id,
		openid:openid,
		city_code:sessionStorage.after_current_area_cityCode,
		db_name:sessionStorage.after_current_area_dbName,
		db_host:sessionStorage.after_current_area_dbHost
	}
	AjaxAfter(data,function(res){
		if(!/^{.*}$/.test(res)){
			return;
		}
		var tmp = JSON.parse(res);
		sessionStorage.admin_token1 = tmp.token1;
		if(tmp.stat == 'ok'){
			A('操作成功！');
			location.reload();
		}else{
			A('请求异常！');
		}
	});
}


//更改小区用户状态
function ChangeAreaUserStat(area_id,openid){
	if(!confirm('确认操作该用户权限？')){
		return;
	}
	var data = {
		type:'ChangeAreaUserStat',
		area_id:area_id,
		openid:openid,
		city_code:sessionStorage.after_current_area_cityCode,
		db_name:sessionStorage.after_current_area_dbName,
		db_host:sessionStorage.after_current_area_dbHost
	}
	AjaxAfter(data,function(res){
		if(!/^{.*}$/.test(res)){
			return;
		}
		var tmp = JSON.parse(res);
		sessionStorage.admin_token1 = tmp.token1;
		if(tmp.stat == 'ok'){
			A('操作成功！');
			location.reload();
		}else{
			A('请求异常！');
		}
	});
}
</script>